package com.ndood.agent.service.system.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import com.ndood.agent.pojo.comm.dto.DataTableDto;
import com.ndood.agent.pojo.system.AgentLogPo;
import com.ndood.agent.pojo.system.dto.LogDto;
import com.ndood.agent.pojo.system.query.AgentLogQo;
import com.ndood.agent.service.system.SystemLogService;

import lombok.extern.slf4j.Slf4j;

/**
 * 日志模块业务类
 */
@Service
@Slf4j
public class SystemLogServiceImpl implements SystemLogService {

	@Autowired
	private ExtendAgentLogDao extendAgentLogDao;
	
	@Override
	public void makeLog(AgentLogPo log) {
		logsDao.save(log);
	}
	
	@Override
	public DataTableDto pageLogList(AgentLogQo query) throws Exception {

		log.debug("Step1: 封装查询参数"); 
		Integer pageSize = query.getLimit();
		String keywords = query.getKeywords();
		Integer pageNo = query.getPageNo();
		Date startTime = query.getStartTime();
		Date endTime = query.getEndTime();
		
		log.debug("Step2: 分页查询出轮播图数据并返回");
		Page<LogDto> page = logRepositoryManager.pageLogList(keywords, startTime, endTime, pageNo, pageSize);
		return new DataTableDto(page.getContent(), page.getTotalElements());
		
	}
	
}
